package com.robotserver.orders.common.vo;

import com.robotserver.orders.constant.ResponseCode;

import java.io.Serializable;

/**
 * 响应结果
 */
public class ResponseResult implements Serializable {
    private static final long serialVersionUID = -26086773651590416L;
    private Integer code = ResponseCode.SUCCESS;
    private String msg;
    private Object data;
    private long time = System.currentTimeMillis();

    public ResponseResult() {
    }

    public ResponseResult(String msg) {
        this.msg = msg;
    }

    public ResponseResult(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ResponseResult(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public ResponseResult(Integer code, String msg, Object data, long time) {
        this.code = code;
        this.msg = msg;
        this.data = data;
        this.time = time;
    }

    public static ResponseResult success(String message){
        return new ResponseResult(ResponseCode.SUCCESS,message);
    }

    public static ResponseResult error(String message){
        return new ResponseResult(ResponseCode.ERROR,message);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public long getTime() {
        return time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    @Override
    public String toString() {
        return "ResponseResult{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                ", time=" + time +
                '}';
    }
}
